<?php

namespace app\admin\model\miniform;

use think\Model;


class Classs extends Model
{

    // 表名
    protected $name = 'baocan_classs';

    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'int';

    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = 'updatetime';
    protected $deleteTime = false;

    // 追加属性
    protected $append = [

    ];

    protected static function init()
    {
        self::afterDelete(function ($row) {
            Student::where('class_id', $row['id'])->delete();
        });
    }

    public function school()
    {
        return $this->belongsTo('School', 'school_id', 'id', [], 'LEFT')->setEagerlyType(0);
    }

}
